package canglang.monitor.cases.service.impl;

import canglang.monitor.cases.dao.CaseUploadDAO;
import canglang.monitor.cases.model.PublishUploadModel;
import canglang.monitor.cases.service.CaseUploadMgr;
import canglang.monitor.core.codelookup.service.CodeLookupMgr;
import canglang.monitor.core.codelookup.model.CodeModel;
import canglang.monitor.core.base.util.ApplicationContextUtil;

import java.util.List;
import java.util.ArrayList;

public class CaseUploadMgrImpl implements CaseUploadMgr {

    private CodeLookupMgr codeLookupMgr;

    private CaseUploadDAO caseUploadDAO;

    public void setCodeLookupMgr(CodeLookupMgr codeLookupMgr) {
        this.codeLookupMgr = codeLookupMgr;
    }

    public void setCaseUploadDAO(CaseUploadDAO caseUploadDAO) {
        this.caseUploadDAO = caseUploadDAO;
    }

    public void uploadFeedbackAttach(PublishUploadModel publishUploadModel) {
          caseUploadDAO.uploadFeedbackAttach(publishUploadModel);
    }

    public List getUploadList(int deptId){
        List list= caseUploadDAO.getUploadList(deptId);
        if(list!=null&&list.size()>0){
            List l=new ArrayList();
            for(int i=0;i<list.size();i++){
                PublishUploadModel p=(PublishUploadModel)list.get(i);
                CodeModel m= codeLookupMgr.getCode("DEPT_LIST",String.valueOf(p.getDeptId()));
                if(m!=null){
                    p.setDeptDesc(m.getCodeDesc());
                }else{
                    p.setDeptDesc("");
                }
                l.add(p);
            }
            return l;
        }
        return list;
    }

    public PublishUploadModel getUploadAttach(int attachId){
        return caseUploadDAO.getUploadAttach(attachId);
    }

    public void deleteFeedbackAttach(int attachId){
        caseUploadDAO.deleteFeedbackAttach(attachId);
    }

}
